/**
 * 
 */
package jp.sourceforge.akjrcp.dropsomething;

import java.util.HashMap;
import java.util.Map;

import jp.sourceforge.akjrcp.akj_betas.Akj_betasPlugin;
import jp.sourceforge.akjrcp.akj_betas.Messages;
import jp.sourceforge.akjrcp.ui.AbstractGenericParametersOptionEditor;
import jp.sourceforge.akjrcp.ui.GenericParametersEventListener;
import jp.sourceforge.akjrcp.ui.GenericParametersFFMpegPreference;
import jp.sourceforge.akjrcp.ui.param.ParamBoolean;
import jp.sourceforge.akjrcp.ui.param.ParamCheckGroup;
import jp.sourceforge.akjrcp.ui.param.ParamCombo;
import jp.sourceforge.akjrcp.ui.param.ParamItem;
import jp.sourceforge.akjrcp.ui.param.ParamRadioGroup;
import jp.sourceforge.akjrcp.ui.param.ParamText;
import jp.sourceforge.akjrcp.util.image.ImageUtils;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;

public class FFMpegOptionEditor extends AbstractGenericParametersOptionEditor implements GenericParametersEventListener{

			Map parameterMap=new HashMap();
			public synchronized Map getParameters(){
				return parameterMap;
			}
			public  void updateParameters(){
				Map parameterMap=new HashMap();
				for (int i = 0; i < paramList.size(); i++) {
					ParamItem item=paramList.get(i);
					if(item.getValue().length()>0){
						parameterMap.put(item.getKey(), item.getValue());
					}
				}
				synchronized(this){
				this.parameterMap=parameterMap;
				}
			}
			
			public void setParameters(Map map){
				for (int i = 0; i < paramList.size(); i++) {
					ParamItem item=paramList.get(i);
					String value=(String) map.get(item.getKey());
					if(value!=null){
						//log.info(item.getKey()+","+value);
						item.setValue(value);
					}else{
						item.setValue("");
					}
				}
			}
			
			
			
			public Composite createOtherControls(Composite parent) {
				return null;
			}
			
			private Object alignCenterGrid() {
				GridData gtop=new GridData();
				gtop.horizontalAlignment=SWT.CENTER;
				return gtop;
			}
			
			public Composite createControls(Composite parent) {
				CTabFolder tab = new CTabFolder(parent, SWT.BOTTOM|SWT.FLAT);
				tab.setLayoutData(new GridData(GridData.FILL_BOTH));
				Composite basicComposite=new Composite(tab,SWT.NONE);
				basicComposite.setLayout(new GridLayout(1,true));
				CTabItem tabItem1 = new CTabItem(tab, SWT.NONE);
				tabItem1.setText(Messages.getString("ffmpegconvert.tab_basic"));
				
				tabItem1.setControl(basicComposite);
				
				
				/*
				twoPass = new Button(composite, SWT.CHECK);
				twoPass.setText(Messages.getString("mpegconvert.twopass"));
				//twoPass.setSelection(getPreferenceStore().getBoolean(PREFERENCE_TWO_PASS));
				twoPass.setToolTipText(Messages
						.getString("mpegconvert.twopass_tooltip"));
				twoPass.addSelectionListener(savePreference);
				twoPass.setVisible(false);//now not support
				*/
				createOtherControls(basicComposite);
				
				
				
				Composite split2=new Composite(basicComposite,SWT.NULL);
				split2.setLayout(new GridLayout(3,false));
				
				Group formatGroup=new Group(split2,SWT.NULL);
				formatGroup.setText(Messages.getString("ffmpegconvert.Export"));
				formatGroup.setLayout(new GridLayout(2,true));
				ParamCombo extension= new ParamCombo(formatGroup,SWT.NONE,"EXTENSION",Messages.getString("ffmpegconvert.Exteision"),
						new String[]{"","flv","mpg","wmv","avi","vob","swf","mp3","ogg","mp2","ac3","aac","wma","mp4","3gp","3g2","mov","m4v","m4a","wav","ts","mkv"});
				extension.setToolTipText(Messages.getString("ffmpegconvert.Exteision_tooltip"));
				addParamList(extension);
				
				ParamCombo f= new ParamCombo(formatGroup,SWT.NONE,"f",Messages.getString("ffmpegconvert.Format"),
						new String[]{"","dvd","mp4","3gp","3g2","psp","mov","s16le","s16be"});
				addParamList(f);
				f.setToolTipText(Messages.getString("ffmpegconvert.Format_tooltip"));
				
				Composite ngGroup=new Composite(split2,SWT.NULL);
				ngGroup.setLayout(new GridLayout(2,false));
				ParamBoolean vn= new ParamBoolean(ngGroup,SWT.NONE,"vn",Messages.getString("ffmpegconvert.vn"));
				vn.setToolTipText(Messages.getString("ffmpegconvert.vn_tooltip"));
				addParamList(vn);
				ParamBoolean an= new ParamBoolean(ngGroup,SWT.NONE,"an",Messages.getString("ffmpegconvert.an"));
				an.setToolTipText(Messages.getString("ffmpegconvert.an_tooltip"));
				addParamList(an);
				
				Group group_time=new Group(split2,SWT.NULL);
				group_time.setText(Messages.getString("ffmpegconvert.Time"));
				GridLayout timeLayout=new GridLayout(2,false);
				timeLayout.horizontalSpacing=0;
				//timeLayout.verticalSpacing=0;
				//timeLayout.marginHeight=0;
				timeLayout.marginWidth=0;
				group_time.setLayout(timeLayout);
				//group_time.setLayout(new GridLayout(2,false));
				
				ParamCombo ss= new ParamCombo(group_time,SWT.NONE,"ss",Messages.getString("ffmpegconvert.start"),new String[]{"","0:0:5","0:0:10","0:0:30","0:0:45","0:1:0","0:3:0","0:15:0","0:30:0","0:45:0","1:0:0","1:15:0","1:30:0","1:45:0","2:0:0"});
				addParamList(ss);
				ss.setToolTipText(Messages.getString("ffmpegconvert.start_tooltip"));
				ParamCombo t= new ParamCombo(group_time,SWT.NONE,"t",Messages.getString("ffmpegconvert.duration"),new String[]{"","0:0:5","0:0:10","0:0:30","0:0:45","0:1:0","0:3:0","0:15:0","0:30:0","0:45:0","1:0:0","1:15:0","1:30:0","1:45:0","2:0:0"});
				t.setToolTipText(Messages.getString("ffmpegconvert.duration_tooltip"));
				addParamList(t);
				
				
				Group vgroup=new Group(basicComposite,SWT.NULL);
				vgroup.setLayout(new GridLayout(3,false));
				vgroup.setText(Messages.getString("ffmpegconvert.Video"));
				GridData vdata=new GridData();
				vdata.minimumHeight=120;
				vdata.grabExcessVerticalSpace=false;
				vgroup.setLayoutData(vdata);
				
				
				
				ParamCombo vcodec= new ParamCombo(vgroup,SWT.NONE,"vcodec",Messages.getString("ffmpegconvert.vcodec"),
						new String[]{"","copy","h264","mpeg4","xvid","mpeg1video","mpeg2video","huffyuv","mjpeg","msmpeg4v2","wmv1","wmv2","rawvideo"});
				vcodec.setToolTipText(Messages.getString("ffmpegconvert.vcodec_tooltip"));
				addParamList(vcodec);
				
				ParamCombo maxfr= new ParamCombo(vgroup,SWT.NONE,GenericParametersFFMpegPreference.MAX_FRAME_RATE,Messages.getString("ffmpegconvert.maxframerate"),
						new String[]{"","30","12","14.895","15","24","25","29.97"});
				maxfr.setToolTipText(Messages.getString("ffmpegconvert.maxframerate_tooltip"));
				addParamList(maxfr);
				
				ParamCombo r= new ParamCombo(vgroup,SWT.NONE,"r",Messages.getString("ffmpegconvert.rate"),
						new String[]{"","1","12","14.895","15","20","23.98","24","25","29.97","30","ntsc","pal"});
				r.setToolTipText(Messages.getString("ffmpegconvert.rate_tooltip"));
				addParamList(r);
				
				ParamCombo s= new ParamCombo(vgroup,SWT.NONE,"s",Messages.getString("ffmpegconvert.size"),
						new String[]{"","120x90","176x144","176x144","208x176","416x352","208x208","320x240","512x384","640x352","640x480","720x480","852x480",
				"1280x544","1280x720","1280x1080","1440x1080","1920x1080"	
				});
//				"160x128","176x96","176x128","176x144","208x176"
				s.setToolTipText(Messages.getString("ffmpegconvert.size_tooltip"));
				addParamList(s);
				
				ParamCombo b= new ParamCombo(vgroup,SWT.NONE,"b",Messages.getString("ffmpegconvert.bitrate"),
						new String[]{"","192k","250k","384k","448k","500k","576k","628k","700k","768k","1000k","1208k","1536k","3072k","4000k","5000k","6000k","7000k","8000k","9000k","10240k","20000k"});
				b.setToolTipText(Messages.getString("ffmpegconvert.bitrate_tooltip"));
				addParamList(b);
				
				
				ParamCombo vtag= new ParamCombo(vgroup,SWT.NONE,"vtag",Messages.getString("ffmpegconvert.vtag"),
						new String[]{"","XVID","mp4v","DX50","VP6F","VP62"});
				vtag.setToolTipText(Messages.getString("ffmpegconvert.vtag_tooltip"));
				addParamList(vtag);
				
				
				ParamCombo aspect= new ParamCombo(vgroup,SWT.NONE,"aspect",Messages.getString("ffmpegconvert.aspect"),
						new String[]{"","4:3","16:9"});
				aspect.setToolTipText(Messages.getString("ffmpegconvert.aspect_tooltip"));
				addParamList(aspect);
				
			
				
				
				ParamBoolean twopass= new ParamBoolean(vgroup,SWT.NONE,GenericParametersFFMpegPreference.TWO_PASS_ENCODE,Messages.getString("ffmpegconvert.twopassencode"));
				twopass.setToolTipText(Messages.getString("ffmpegconvert.twopassencode_tooltip"));
				addParamList(twopass);
				
				
				ParamBoolean deinterlace= new ParamBoolean(vgroup,SWT.NONE,"deinterlace",Messages.getString("ffmpegconvert.deinterlace"));
				deinterlace.setToolTipText(Messages.getString("ffmpegconvert.deinterlace_tooltip"));
				addParamList(deinterlace);
				
				Group agroup=new Group(basicComposite,SWT.NULL);
				agroup.setText(Messages.getString("ffmpegconvert.Audio"));
				agroup.setLayout(new GridLayout(6,false));
				GridData adata=new GridData();
				adata.minimumHeight=120;
				adata.grabExcessVerticalSpace=false;
				agroup.setLayoutData(adata);
				
				
				
				
				ParamCombo acodec= new ParamCombo(agroup,SWT.NONE,"acodec",Messages.getString("ffmpegconvert.acodec"),
						new String[]{"","copy","pcm_s16le","mp2","ac3","wmav1","wmav2","aac","mp3","ogg"});
				acodec.setToolTipText(Messages.getString("ffmpegconvert.acodec_tooltip"));
				addParamList(acodec);
				
				ParamCombo ab= new ParamCombo(agroup,SWT.NONE,"ab",Messages.getString("ffmpegconvert.ab"),
						new String[]{"","32k","64k","96k","128k","160k","192k","256k","320k","360k","384k","448k"});
				ab.setToolTipText(Messages.getString("ffmpegconvert.ab_tooltip"));
				addParamList(ab);
				
				ParamCombo ar= new ParamCombo(agroup,SWT.NONE,"ar",Messages.getString("ffmpegconvert.ar"),
						new String[]{"","8000","16000","22050","24000","32000","44100","48000"});
				ar.setToolTipText(Messages.getString("ffmpegconvert.ar_tooltip"));
				addParamList(ar);
				
				ParamCombo ac= new ParamCombo(agroup,SWT.NONE,"ac",Messages.getString("ffmpegconvert.ac"),
						new String[]{"","2","1"});
				ac.setToolTipText(Messages.getString("ffmpegconvert.ac_tooltip"));
				addParamList(ac);
				
				ParamCombo vol= new ParamCombo(agroup,SWT.NONE,"vol",Messages.getString("ffmpegconvert.vol"),
						new String[]{"","64","128","224","256","272","288","304","320","352","384","512","640","768","896","1024","2048"});
						
						
						
						
				vol.setToolTipText(Messages.getString("ffmpegconvert.vol_tooltip"));
				addParamList(vol);
				
				Composite timeCropPadComposite=new Composite(tab,SWT.NONE);
				timeCropPadComposite.setLayout(new GridLayout(2,false));
				CTabItem tabItem4 = new CTabItem(tab, SWT.NONE);
				tabItem4.setText(Messages.getString("ffmpegconvert.tab_timecroppad"));
				
				tabItem4.setControl(timeCropPadComposite);
			

				Group group_crop=new Group(timeCropPadComposite,SWT.NULL);
				group_crop.setLayoutData(new GridData(GridData.FILL_VERTICAL));
				group_crop.setText(Messages.getString("ffmpegconvert.Crop"));
				GridLayout cropLayout=new GridLayout(3,false);
				cropLayout.horizontalSpacing=0;
				cropLayout.verticalSpacing=0;
				cropLayout.marginHeight=0;
				cropLayout.marginWidth=0;
				group_crop.setLayout(cropLayout);
				
				new Label(group_crop,SWT.NULL);;//dummy
				ParamText croptop= new ParamText(group_crop,SWT.NONE,"croptop",Messages.getString("ffmpegconvert.croptop"));
				addParamList(croptop);
				
				croptop.setLayoutData(alignCenterGrid());
				new Label(group_crop,SWT.NULL);;//dummy
				
				
				
				ParamText cropleft= new ParamText(group_crop,SWT.NONE,"cropleft",Messages.getString("ffmpegconvert.cropleft"));
				addParamList(cropleft);
				
				Label cropLabel=new Label(group_crop,SWT.NULL);
				cropLabel.setImage(ImageUtils.loadImage(Akj_betasPlugin.PLUGIN_ID, "icons/crop.png"));
				
				
				ParamText cropright= new ParamText(group_crop,SWT.NONE,"cropright",Messages.getString("ffmpegconvert.cropright"));
				addParamList(cropright);
				
				new Label(group_crop,SWT.NULL);;//dummy
				ParamText cropbottom= new ParamText(group_crop,SWT.NONE,"cropbottom",Messages.getString("ffmpegconvert.cropbottom"));
				cropbottom.setLayoutData(alignCenterGrid());
				addParamList(cropbottom);
				new Label(group_crop,SWT.NULL);;//dummy
				
				
				Group group_pad=new Group(timeCropPadComposite,SWT.NULL);
				group_pad.setText(Messages.getString("ffmpegconvert.Padding"));
				GridLayout padLayout=new GridLayout(3,false);
				padLayout.horizontalSpacing=0;
				padLayout.verticalSpacing=0;
				padLayout.marginHeight=0;
				padLayout.marginWidth=0;
				group_pad.setLayout(padLayout);
				
				new Label(group_pad,SWT.NULL);;//dummy
				ParamText padtop= new ParamText(group_pad,SWT.NONE,"padtop",Messages.getString("ffmpegconvert.padtop"));
				padtop.setLayoutData(alignCenterGrid());
				addParamList(padtop);
				new Label(group_pad,SWT.NULL);;//dummy
				
				ParamText padleft= new ParamText(group_pad,SWT.NONE,"padleft",Messages.getString("ffmpegconvert.padleft"));
				addParamList(padleft);
				new Label(group_pad,SWT.NULL).setImage(ImageUtils.loadImage(Akj_betasPlugin.PLUGIN_ID, "icons/pad.png"));
				ParamText padright= new ParamText(group_pad,SWT.NONE,"padright",Messages.getString("ffmpegconvert.padright"));
				addParamList(padright);
				
				new Label(group_pad,SWT.NULL);;//dummy
				ParamText padbottom= new ParamText(group_pad,SWT.NONE,"padbottom",Messages.getString("ffmpegconvert.padbottom"));
				padbottom.setLayoutData(alignCenterGrid());
				addParamList(padbottom);
				ParamCombo padcolor= new ParamCombo(group_pad,SWT.NONE,"padcolor",Messages.getString("ffmpegconvert.padcolor"),
						new String[]{"","000000","ffffff"});
				padcolor.setToolTipText(Messages.getString("ffmpegconvert.padcolor_tooltip"));
				padcolor.setLayoutData(alignCenterGrid());
				addParamList(padcolor);
				
				
				Composite advancedComposite=new Composite(tab,SWT.NONE);
				advancedComposite.setLayout(new GridLayout(1,true));
				CTabItem tabItem2 = new CTabItem(tab, SWT.NONE);
				tabItem2.setText(Messages.getString("ffmpegconvert.tab_advanced1"));
				
				tabItem2.setControl(advancedComposite);
				
				
				ParamCheckGroup flags=new ParamCheckGroup(advancedComposite,SWT.NONE,"flags","flags",
						new String[]{"mv4","obmc","qpel","loop","gmc","mv0","part","gray","psnr","naq","ildct","low_delay",
						"alt","bitexact","aic","umv","cbp","qprd","aiv","slice","ilme","scan_offset","cgop"},12);
				addParamList(flags);
				String text="";
				text+="-flags             <flags> EDVA.\n";
				text+="   mv4                     E.V.. use four motion vector by macroblock (mpeg4)\n";
				text+="   obmc                    E.V.. use overlapped block motion compensation (h263+)\n";
				text+="   qpel                    E.V.. use 1/4 pel motion compensation\n";
				text+="   loop                    E.V.. use loop filter\n";
				text+="   gmc                     E.V.. use gmc\n";
				text+="   mv0                     E.V.. always try a mb with mv=<0,0>\n";
				text+="   part                    E.V.. use data partitioning\n";
				text+="   gray                    EDV.. only decode/encode grayscale\n";
				text+="   psnr                    E.V.. error[?] variables will be set during encoding\n";
				text+="   naq                     E.V.. normalize adaptive quantization\n";
				text+="   ildct                   E.V.. use interlaced dct\n";
				text+="   low_delay               EDV.. force low delay\n";
				text+="   alt                     E.V.. enable alternate scantable (mpeg2/mpeg4)\n";
				text+="   bitexact                EDVAS use only bitexact stuff (except (i)dct)\n";
				text+="   aic                     E.V.. h263 advanced intra coding / mpeg4 ac prediction\n";
				text+="   umv                     E.V.. use unlimited motion vectors\n";
				text+="   cbp                     E.V.. use rate distortion optimization for cbp\n";
				text+="   qprd                    E.V.. use rate distortion optimization for qp selection\n";
				text+="   aiv                     E.V.. h263 alternative inter vlc\n";
				text+="   slice                   E.V..\n";
				text+="   ilme                    E.V.. interlaced motion estimation\n";
				text+="   scan_offset             E.V.. will reserve space for svcd scan offset user data\n";
				text+="   cgop                    E.V.. closed gop\n";

				flags.setToolTipText(text);
				
				/*
				 * do advanced
				 */
				Group group1=new Group(advancedComposite,SWT.NULL);
				group1.setLayout(new GridLayout(7,false));
				
				
		
		
				ParamCombo b_strategy= new ParamCombo(group1,SWT.NONE,"b_strategy","b_strategy",
						new String[]{"","0","1"});
				addParamList(b_strategy);
				
			
				/*
				ParamCombo max_b_frames= new ParamCombo(group1,SWT.NONE,"max_b_frames","max_b_frames",
						new String[]{"","0","1"});
				addParamList(max_b_frames);
				*/
				
				ParamCombo trellis= new ParamCombo(group1,SWT.NONE,"trellis","trellis",
						new String[]{"","0","1","2"});
				addParamList(trellis);
				
				ParamCombo refs= new ParamCombo(group1,SWT.NONE,"refs","refs",
						new String[]{"","0","1","2","3","4","5"});
				addParamList(refs);
				
				ParamCombo bf= new ParamCombo(group1,SWT.NONE,"bf","bf",
						new String[]{"","0","1","2","3","4","5"});
				addParamList(bf);
				
				
				
				ParamCombo coder= new ParamCombo(group1,SWT.NONE,"coder","coder",
						new String[]{"","0","1"});
				addParamList(coder);
				
				ParamCombo g= new ParamCombo(group1,SWT.NONE,"g","g",
						new String[]{"","12","18","32","50","100","200","250","300"});
				addParamList(g);
				
			
				
				ParamCombo deblockalpha= new ParamCombo(group1,SWT.NONE,"deblockalpha","deblockalpha",
						new String[]{"","0","1"});
				addParamList(deblockalpha);
				
				ParamCombo deblockbeta= new ParamCombo(group1,SWT.NONE,"deblockbeta","deblockbeta",
						new String[]{"","0","1"});
				addParamList(deblockbeta);
				
				ParamCombo mbd= new ParamCombo(group1,SWT.NONE,"mbd","mbd",
						new String[]{"","0","1","rd"});
				addParamList(mbd);
				
				ParamCombo chroma= new ParamCombo(group1,SWT.NONE,"chroma","chroma",
						new String[]{"","0","1"});
				addParamList(chroma);
				
				ParamCombo brdo= new ParamCombo(group1,SWT.NONE,"brdo","brdo",
						new String[]{"","0","1"});
				addParamList(brdo);
				
				
				
				ParamCombo slice= new ParamCombo(group1,SWT.NONE,"slice","slice",
						new String[]{"","0","1","2"});
				addParamList(slice);
				

				ParamCombo subq= new ParamCombo(group1,SWT.NONE,"subq","subq",
						new String[]{"","0","1","2","3","4","5","6","7","8","9"});
				addParamList(subq);
				
				
				ParamCombo sc_threshold= new ParamCombo(group1,SWT.NONE,"sc_threshold","sc_threshold",
						new String[]{"","0","1","40"});
				addParamList(sc_threshold);
				
				
				ParamCombo i_qfactor= new ParamCombo(group1,SWT.NONE,"i_qfactor","i_qfactor",
						new String[]{"","0","0.71","0.71428572"});
				addParamList(i_qfactor);
				ParamCombo qmin= new ParamCombo(group1,SWT.NONE,"qmin","qmin",
						new String[]{"","0","1","3","7","10","23"});
				addParamList(qmin);
				
				ParamCombo qmax= new ParamCombo(group1,SWT.NONE,"qmax","qmax",
						new String[]{"","1","5","25","35","40","51"});
				addParamList(qmax);
				
				ParamCombo qdiff= new ParamCombo(group1,SWT.NONE,"qdiff","qdiff",
						new String[]{"","0","1","2","3","4"});
				addParamList(qdiff);
				
				
				ParamCombo loop= new ParamCombo(group1,SWT.NONE,"loop","loop",
						new String[]{"","0","1"});
				addParamList(loop);
				
				ParamCombo qscale= new ParamCombo(group1,SWT.NONE,"qscale","qscale",
						new String[]{"","1","5"});
				addParamList(qscale);
				
				ParamCombo target= new ParamCombo(group1,SWT.NONE,"target","target",
						new String[]{"","ntsc-dvd","ntsc-vcd","dvd","vcd","dv"});
				addParamList(target);
				
				ParamCombo profile= new ParamCombo(group1,SWT.NONE,"profile","profile",
						new String[]{"","aac_main","aac_low","aac_ssr","aac_ltp"});
				
				addParamList(profile);
				
			
				
				
				ParamCombo qcomp= new ParamCombo(group1,SWT.NONE,"qcomp","qcomp",
						new String[]{"","0","0.6"});
				addParamList(qcomp);
				
				ParamCombo keyint_min= new ParamCombo(group1,SWT.NONE,"keyint_min","keyint_min",
						new String[]{"","0","1","25"});
				addParamList(keyint_min);
				

				
				
				Group group2=new Group(advancedComposite,SWT.NULL);
				group2.setLayout(new GridLayout(6,false));
				
				ParamCombo cmp= new ParamCombo(group2,SWT.NONE,"cmp","cmp",
						new String[]{"","sad","sse","satd","dct","psnr","bit","rd","zero","vsad","vsse","sad","w53","w97","dctmax","chroma"});
				addParamList(cmp);
				
				ParamCombo subcmp= new ParamCombo(group2,SWT.NONE,"subcmp","subcmp",
						new String[]{"","sad","sse","satd","dct","psnr","bit","rd","zero","vsad","vsse","sad","w53","w97","dctmax","chroma"});
				addParamList(subcmp);
				
				ParamCombo rc_eq= new ParamCombo(group2,SWT.NONE,"rc_eq","rc_eq",
						new String[]{"","\"blurCplx^(1-qComp)\""});
				addParamList(rc_eq);
				
				
				ParamCombo me_method= new ParamCombo(group2,SWT.NONE,"me_method","me_method",
						new String[]{"","zero","full","epzs","esa","tesa","dig","log","phods","x1","hex","umh","iter"});
				addParamList(me_method);
				
				
				ParamCombo me_range= new ParamCombo(group2,SWT.NONE,"me_range","me_range",
						new String[]{"","16","21"});
				addParamList(me_range);
				


				ParamCombo bt= new ParamCombo(group2,SWT.NONE,"bt","bt",
						new String[]{"250k","384k","500k","700k","768k","1000k","1536k","3072k"});
				addParamList(bt);
				
				ParamCombo bufsize= new ParamCombo(group2,SWT.NONE,"bufsize","bufsize",
						new String[]{"224k","384k","700k","768k","1536k","3072k","4096k"});
				addParamList(bufsize);
				
				ParamCombo maxrate= new ParamCombo(group2,SWT.NONE,"maxrate","maxrate",
						new String[]{"384k","768k","1000k","1300k","1536k","3072k","4000k","9000k","10000k"});
				addParamList(maxrate);
				
				ParamCombo minrate= new ParamCombo(group2,SWT.NONE,"minrate","minrate",
						new String[]{"384k","768k","1000k","1300k","1536k","3072k","4000k","9000k","10000k"});
				addParamList(minrate);
				
				ParamCombo crf= new ParamCombo(group1,SWT.NONE,"crf","crf",
						new String[]{"15","20","26","32","34"});
				addParamList(crf);
				
				ParamCombo directpred= new ParamCombo(group1,SWT.NONE,"directpred","directpred",
						new String[]{"0","1","2","3"});
				addParamList(directpred);
				
				
				ParamCombo bider_refine= new ParamCombo(group1,SWT.NONE,"bider_refine","bider_refine",
						new String[]{"1"});
				addParamList(bider_refine);
				
				ParamCombo async= new ParamCombo(group1,SWT.NONE,"async","async",
						new String[]{"","1","10","50","100","250","500","1000"});
				addParamList(async);
				
				ParamCombo pix_fmt= new ParamCombo(group2,SWT.NONE,"pix_fmt","pix_fmt",
						new String[]{"","rgb24","bgr24","rgba32","rgb565","rgb555","yuv420p","yuv422p","yuv444p","yuv422","yuv410p","yuv411p","yuvj420p","yuvj422p","yuvj444p","gray","monow","monob","pal8"});
				addParamList(pix_fmt);
				
				ParamCombo level= new ParamCombo(group2,SWT.NONE,"level","level",
						new String[]{"13","21","30"});
				addParamList(level);
				
				ParamBoolean sameq= new ParamBoolean(group2,SWT.NONE,"sameq","sameq");
				addParamList(sameq);
				
				ParamCombo dia_size= new ParamCombo(group2,SWT.NONE,"dia_size","dia_size",
						new String[]{""});
				addParamList(dia_size);
				
				ParamCombo vsync= new ParamCombo(group2,SWT.NONE,"vsync","vsync",
						new String[]{"","0","1"});
				addParamList(vsync);
				
			
				
				
				
				
				
				
				
				

				Composite advancedComposite2=new Composite(tab,SWT.NONE);
				advancedComposite2.setLayout(new GridLayout(1,true));
				CTabItem tabItem3 = new CTabItem(tab, SWT.NONE);
				tabItem3.setText(Messages.getString("ffmpegconvert.tab_advanced2"));
				
				tabItem3.setControl(advancedComposite2);
				
				
				

				ParamCheckGroup flags2=new ParamCheckGroup(advancedComposite2,SWT.NONE,"flags2","flags2",
						new String[]{"fast","sgop","noout","local_header","bpyramid","wpred","mixed_refs","dct8x8","fastpskip","aud","brdo","skiprd",
						"ivlc","drop_frame_timecode","non_linear_q"},8);
				addParamList(flags2);
				String text2="";
				text2+="-flags2            <flags> EDVA.\n";
				text2+="   fast                    E.V.. allow non spec compliant speedup tricks\n";
				text2+="   sgop                    E.V.. strictly enforce gop size\n";
				text2+="   noout                   E.V.. skip bitstream encoding\n";
				text2+="   local_header            E.V.. place global headers at every keyframe instead of in extradata\n";
				text2+="   bpyramid                E.V.. allows B-frames to be used as references for predicting\n";
				text2+="   wpred                   E.V.. weighted biprediction for b-frames (H.264)\n";
				text2+="   mixed_refs              E.V.. one reference per partition, as opposed to one reference per macroblock\n";
				text2+="   dct8x8                  E.V.. high profile 8x8 transform (H.264)\n";
				text2+="   fastpskip               E.V.. fast pskip (H.264)\n";
				text2+="   aud                     E.V.. access unit delimiters (H.264)\n";
				text2+="   brdo                    E.V.. b-frame rate-distortion optimization\n";
				text2+="   skiprd                  E.V.. RD optimal MB level residual skipping\n";
				text2+="   ivlc                    E.V.. intra vlc table\n";
				text2+="   drop_frame_timecode         E.V..\n";
				text2+="   non_linear_q            E.V.. use non linear quantizer\n";
				flags2.setToolTipText(text2);
				
				
				
				
				
			
				
				
				ParamCheckGroup debug=new ParamCheckGroup(advancedComposite2,SWT.NONE,"debug","debug",
						new String[]{"pict","rc","bitstream","qp","mv","dct_coeff","skip","startcode","pts","er","mmco","bugs","vis_qp","vis_mb_type"},8);
				addParamList(debug);
				
				ParamCheckGroup partisions=new ParamCheckGroup(advancedComposite2,SWT.NONE,"partitions","partitions",
						new String[]{"parti4x4","parti8x8","partp4x4","partp8x8","partb8x8"},5);
				partisions.setToolTipText("-partitions        <flags> E.V.. macroblock subpartition sizes to consider");
				addParamList(partisions);
				
				ParamRadioGroup afterActions=new ParamRadioGroup(advancedComposite2,SWT.NONE,"AFTER_ACTION",Messages.getString("dropffmpeg.after_action"),
						new String[]{"","jp.sourceforge.akjrcp.dropsomething.actions.MakePSPThumbnailAction","jp.sourceforge.akjrcp.dropsomething.actions.IPodAtomicParsleyAction","jp.sourceforge.akjrcp.dropsomething.actions.AsfbinIndexAction","jp.sourceforge.akjrcp.dropsomething.actions.CustomAction"},
						new String[]{Messages.getString("dropffmpeg.none_action"),Messages.getString("dropffmpeg.make_psp_thumbnail"),Messages.getString("dropffmpeg.update_atomicparsely"),Messages.getString("dropffmpeg.index_asfbin"),Messages.getString("ffmpegsetting.custom_command")},3);
				partisions.setToolTipText("");
				addParamList(afterActions);
				
				/*
				 *    pict                    .DV.. picture info
	   rc                      E.V.. rate control
	   bitstream               .DV..
	   mb_type                 .DV.. macroblock (MB) type
	   qp                      .DV.. per-block quantization parameter (QP)
	   mv                      .DV.. motion vector
	   dct_coeff               .DV..
	   skip                    .DV..
	   startcode               .DV..
	   pts                     .DV..
	   er                      .DV.. error resilience
	   mmco                    .DV.. memory management control operations (H.264)
	   bugs                    .DV..
	   vis_qp                  .DV.. visualize quantization parameter (QP), lower QP are tinted greener
	   vis_mb_type             .DV.. visualize block types
				 */
				advancedComposite.setFocus();
				tab.setSelection(0);
				tab.forceFocus();//must for focus tab.
				
				//important for event
				this.addListener(this);
				
				return tab;
			}
			public void updateModified(boolean modified) {
				updateParameters();
			}
			@Override
			public void updateStatus() {
				//throw new RuntimeException("not implement yet");
			}
			@Override
			public ParamItem getItem(String key) {
				throw new RuntimeException("not implement yet");
				
			}
		
			
		}